/**
 * 产品数据RESTful
 * Created by Administrator on 15-3-17.
 */

var router = require('express').Router();
var productServices = require('../services/Product');

router.get('/', function (req, res) {
    res.render('home/products', {});
});

router.get('/content/:_id', function (req, res) {
    res.render('home/product', {});
});

//获取产品列表    -----------------------------------------------------------------------------------
/*
* @param: now  ----    当前页面的最后一个产品的id
* @param: num  ----    要加载的个数
* */
router.get('/list', function(req, res) {

    var page = req.query;
    productServices.list(page, function (err, returnPage) {

        if (err) {
            res.statusCode = 500;
            res.send({});
        }
        res.statusCode = 200;
        res.send(returnPage);
    });
});

module.exports = router;
